package com.pro.utils;
import com.pro.entity.ClosurePlus;
import com.pro.service.UserListService;
import com.pro.service.imple.UserListServiceImple;
import jdk.internal.dynalink.beans.StaticClass;
import lombok.SneakyThrows;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.lang.reflect.Array;
import java.time.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author ：刘弘禹
 * @description：TODO
 * @date ：2021/12/2 19:13
 * Quartz 定时器
 */
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class PrintWordsJob extends QuartzJobBean {
    @Autowired
    private UserListService userListService;

    @Override
    public void executeInternal(JobExecutionContext context) throws JobExecutionException {

        List<ClosurePlus> unsealingTime = userListService.getUnsealingTime();
        for (ClosurePlus closurePlus : unsealingTime) {
            if(DateUtils.transString(closurePlus.getEndDate()).getTime() < new Date().getTime()){
                userListService.unseal(closurePlus.getId(),closurePlus.getUserId(),null);
            }
        }

    }
}



